@isTest(SeeAllData=true)
private class QuerySFMeasageRESTTest {
    static testMethod void testMethod1() {
        
        Id engProfile = [Select Id From Profile Where Name ='销售部直销销售员'].Id;
        Id engProfile1 = [Select Id From Profile Where Name ='销售部直销经理/主管'].Id;
        User mana = new User( Alias = 'samLdc1', 
                         Email = 'ldc@test.com.maike',
                         Emailencodingkey = 'UTF-8', 
                         Lastname = '用户1', 
                         Languagelocalekey = 'en_US',
                         Localesidkey = 'en_US', 
                         Profileid = engProfile1, 
                          SalesAssistant__c = UserInfo.getUserId(),
                          FinancialManager__c = UserInfo.getUserId(),
                         Country = 'United States',
                         IsActive = true,
                         SubCompany__c='四川省迈克实业有限公司',
                         UserDepartment__c='西区销售中心(陕西省)',
                         Timezonesidkey = 'America/Los_Angeles', 
                         EmployeeNumber = '123451',
                         Username = 'Matldc1@test.com.maike' );

       
        insert mana; 

          User appMan1 = new User( Alias = 'samLdc2', 
                         Email = 'samLdc2@test.com.maike',
                         Emailencodingkey = 'UTF-8', 
                         Lastname = '用户2', 
                         ManagerId = mana.Id ,
                         Languagelocalekey = 'en_US',
                         Localesidkey = 'en_US', 
                         Profileid = engProfile, 
                         Country = 'United States',
                         IsActive = true,
                         SalesAssistant__c = UserInfo.getUserId(),
                          FinancialManager__c = UserInfo.getUserId(),
                         SubCompany__c='四川省迈克实业有限公司',
                         UserDepartment__c='西区销售中心(陕西省)',
                         Timezonesidkey = 'America/Los_Angeles', 
                         EmployeeNumber = '123452',
                         Username = 'samLdc2@test.com.maike' );
        
       
        insert appMan1; 
     

       Task t = new Task();
       t.Subject = 'test';
       t.Status = 'Open';
       t.OwnerId = mana.Id ; 
       insert t ; 


       ProductStructure__c ps = new ProductStructure__c();
        ps.Classify3__c = '试剂';
        insert ps;
        Product__c p1 = TestUtils.createProduct();
        p1.Category0__c = '试剂';
        p1.ProductStructure__c = ps.Id;
        p1.PriceCompany__c = 'MKSY';
        p1.NCCode__c = '000001';
        p1.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('NCProduct', 'Product__c');
        
        Product__c p2 = TestUtils.createProduct();
        p2.Category0__c = '试剂';
        p2.ProductStructure__c = ps.Id;
        p2.PriceCompany__c = 'MKSY';
        p2.NCCode__c = '000002';
        p2.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('NCProduct', 'Product__c');
        insert new Product__c[] {p1, p2};


       Account acc = TestUtils.createAccount();
        acc.Level__c = '一级医院';
        acc.Name = 'test1112445';
        insert acc;

        AdjustPrice__c ap = new AdjustPrice__c();
        ap.Account__c = acc.Id;
        ap.SalesCode__c = '05';
        ap.OwnerId = appMan1.Id ; 
        insert ap;
        AdjustPriceProduct__c app = new AdjustPriceProduct__c();
        app.AdjustPrice__c = ap.Id;
        app.Product__c = p1.Id;
        app.OriginalPrice__c = 1;
        app.AdjustSalesPrice__c = 2;
        insert app;


		

       
		 Approval.ProcessSubmitRequest req1 =
        new Approval.ProcessSubmitRequest();
        req1.setObjectId(ap.id);
        req1.setSubmitterId(appMan1.Id);
        Approval.ProcessResult result = Approval.process(req1);

	     /*List<Id> newWorkItemIds = result.getNewWorkitemIds();


 		  Approval.ProcessWorkitemRequest req2 =
            new Approval.ProcessWorkitemRequest();
        req2.setComments('Approving request.');
        req2.setAction('Approve');
        req2.setNextApproverIds(new Id[]{mana.Id});
		req2.setWorkitemId(newWorkItemIds.get(0));
        Approval.ProcessResult result2 =  Approval.process(req2);*/
    	
       
      
      


		String p = EncodingUtil.base64Encode(Blob.valueOf('3451'));
		String ts = String.valueOf(System.now().getTime());
 		String sign= EncodingUtil.convertToHex(Crypto.generateDigest('MD5',Blob.valueOf(ts+p + ts)));
		System.debug(QuerySFMeasageREST.querySFMeasage(p,  ts,  sign));
        QuerySFMeasageREST.setResult('ss');
    }
}